<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>服务端开发指南 | wflow文档</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/favicon.ico">
    <meta name="description" content="wflow工作流">
    
    <link rel="preload" href="/assets/css/0.styles.ce1b68d2.css" as="style"><link rel="preload" href="/assets/js/app.5597d7ea.js" as="script"><link rel="preload" href="/assets/js/2.55e01133.js" as="script"><link rel="preload" href="/assets/js/14.a398dcf5.js" as="script"><link rel="prefetch" href="/assets/js/10.a0f5f85b.js"><link rel="prefetch" href="/assets/js/11.e142bee0.js"><link rel="prefetch" href="/assets/js/12.eaf3ad2b.js"><link rel="prefetch" href="/assets/js/13.69edbca2.js"><link rel="prefetch" href="/assets/js/15.f57efa7f.js"><link rel="prefetch" href="/assets/js/16.6e62d6c4.js"><link rel="prefetch" href="/assets/js/3.006c0914.js"><link rel="prefetch" href="/assets/js/4.9591ee34.js"><link rel="prefetch" href="/assets/js/5.d03914b4.js"><link rel="prefetch" href="/assets/js/6.7037ec4a.js"><link rel="prefetch" href="/assets/js/7.2bcf5791.js"><link rel="prefetch" href="/assets/js/8.e0421f00.js"><link rel="prefetch" href="/assets/js/9.47c392ae.js">
    <link rel="stylesheet" href="/assets/css/0.styles.ce1b68d2.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo.png" alt="wflow文档" class="logo"> <span class="site-name can-hide">wflow文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="https://gitee.com/willianfu/jw-workflow-engine" target="_blank" rel="noopener noreferrer" class="nav-link external">
  码云gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="http:/47.100.202.245:83" target="_blank" rel="noopener noreferrer" class="nav-link external">
  访问 wflow在线演示
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="/pro.html" class="nav-link">
  wflow-pro
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="https://gitee.com/willianfu/jw-workflow-engine" target="_blank" rel="noopener noreferrer" class="nav-link external">
  码云gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="http:/47.100.202.245:83" target="_blank" rel="noopener noreferrer" class="nav-link external">
  访问 wflow在线演示
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="/pro.html" class="nav-link">
  wflow-pro
</a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>🚀 快速入门</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/start/quickStart.html" class="sidebar-link">开始</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>✍ 开发</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/dev/project.html" class="sidebar-link">项目介绍</a></li><li><a href="/dev/form.html" class="sidebar-link">表单设计</a></li><li><a href="/dev/process.html" class="sidebar-link">流程设计</a></li><li><a href="/dev/server.html" aria-current="page" class="active sidebar-link">服务端开发指南</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/dev/server.html#基本要求" class="sidebar-link">基本要求</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/dev/server.html#组织机构选择器" class="sidebar-link">组织机构选择器</a></li></ul></li><li class="sidebar-sub-header"><a href="/dev/server.html#流程解析" class="sidebar-link">流程解析</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/dev/server.html#wflow节点与bpmn概念对应关系" class="sidebar-link">wflow节点与Bpmn概念对应关系</a></li></ul></li></ul></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>❓ FAQ</span> <!----></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="服务端开发指南"><a href="#服务端开发指南" class="header-anchor">#</a> 服务端开发指南</h1> <p>目前只开源了前端设计器部分，大家配套后端使用的话，需要自行开发服务端应用，可以参考如下说明</p> <h2 id="基本要求"><a href="#基本要求" class="header-anchor">#</a> 基本要求</h2> <h3 id="组织机构选择器"><a href="#组织机构选择器" class="header-anchor">#</a> 组织机构选择器</h3> <p>组织机构选择器由于在项目很多地方引用了，如果在不修改组件代码的情况下，建议按如下规则适配</p> <blockquote><p>该组件存在于 <code>src\components\common\organizationPicker.vue</code>，对应API接口在 <code>src/api/org.js</code>，有2个接口，分别如下</p></blockquote> <h4 id="获取组织架构列表"><a href="#获取组织架构列表" class="header-anchor">#</a> 获取组织架构列表</h4> <p>方法： <code>getOrgTree</code></p> <p>URL：<code>/oa/org/tree</code></p> <p>请求类型：<code>GET</code></p> <p>参数：</p> <ul><li>deptId： 当前选中的部门ID</li> <li>type：<code>user</code> - 返回部门和部门内的人员   <code>dept</code>-只返回部门</li></ul> <p>返回结果：（部门和人员结构一致，注意部门应当排序在前）</p> <div class="language-json line-numbers-mode"><pre class="language-json"><code><span class="token punctuation">[</span>
	<span class="token punctuation">{</span>
		<span class="token property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;部门/人员ID&quot;</span><span class="token punctuation">,</span>
		<span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;部门/人员名&quot;</span><span class="token punctuation">,</span>
		<span class="token property">&quot;avatar&quot;</span><span class="token operator">:</span><span class="token string">&quot;人员的头像的 base64 / url&quot;</span><span class="token punctuation">,</span>
        <span class="token property">&quot;type&quot;</span><span class="token operator">:</span> <span class="token string">&quot;本数据对象的类型，user/dept&quot;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h4 id="按拼音-姓名搜索人员"><a href="#按拼音-姓名搜索人员" class="header-anchor">#</a> 按拼音/姓名搜索人员</h4> <blockquote><p>当在搜索框直接输入拼音/姓名时，将会发起搜索请求，后端应当根据参数内容匹配用户的姓名或者姓名拼音</p></blockquote> <p>方法： <code>getUserByName</code></p> <p>URL：<code>oa/org/tree/user/search</code></p> <p>请求类型：<code>GET</code></p> <p>参数：</p> <ul><li>userName：搜索参数</li></ul> <p>返回结果：（人员列表）</p> <div class="language-json line-numbers-mode"><pre class="language-json"><code><span class="token punctuation">[</span>
	<span class="token punctuation">{</span>
		<span class="token property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;人员ID&quot;</span><span class="token punctuation">,</span>
		<span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;人员名&quot;</span><span class="token punctuation">,</span>
		<span class="token property">&quot;avatar&quot;</span><span class="token operator">:</span><span class="token string">&quot;人员的头像的 base64 / url&quot;</span><span class="token punctuation">,</span>
        <span class="token property">&quot;type&quot;</span><span class="token operator">:</span> <span class="token string">&quot;本数据对象的类型，user&quot;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h2 id="流程解析"><a href="#流程解析" class="header-anchor">#</a> 流程解析</h2> <p>流程的数据存储在 vuex的 <code>state.design.process</code>中，由于序列化后是json结构，非标准 Bpmn，因此需要在后端做转换，也建议在后端进行转换。</p> <p>最常用的Java开源流程引擎有 <code>activiti</code> 、<code>Flowable</code> ，两者同源，差不多用法，都提供了使用代码Api来构建Xml的功能。</p> <h3 id="wflow节点与bpmn概念对应关系"><a href="#wflow节点与bpmn概念对应关系" class="header-anchor">#</a> wflow节点与Bpmn概念对应关系</h3> <h4 id="发起人"><a href="#发起人" class="header-anchor">#</a> 发起人</h4> <p><code>发起人</code> 可以映射为<code>startEvent</code>，也可以忽略，发起人主要是为了设置哪些人可以发起该流程，也就是该流程的权限，并且也是默认的候选条件</p> <h4 id="审批人"><a href="#审批人" class="header-anchor">#</a> 审批人</h4> <p>审批人对应 <code>UserTask</code> ，该节点是需要审批人对发起人提交的表单进行处理，以及如果有需要的话也可以修改提交的表单（要设置表单可编辑权限）</p> <p>审批意味着主要是做两件事，<code>同意/驳回</code> ，同意就进入下一任务， 而驳回的策略有两种，默认直接驳回到<code>EndEvent</code> ,如果设置了则驳回到指定节点，因为有2种结果分流，所以此处应该设置条件顺序流。</p> <h4 id="抄送人"><a href="#抄送人" class="header-anchor">#</a> 抄送人</h4> <p>抄送人对应 <code>ServiceTask</code>，应当掉用java指定的功能类，传入参数执行发送通知的功能</p> <h4 id="延时处理"><a href="#延时处理" class="header-anchor">#</a> 延时处理</h4> <p>延时处理对应 <code>intermediateCatchEvent</code>，设置为定时器类型的中间事件，根据配置解析</p> <h4 id="触发器"><a href="#触发器" class="header-anchor">#</a> 触发器</h4> <p>触发器对应 <code>ServiceTask</code>，应当掉用java指定的功能类，传入参数执行Http请求或者发邮件，由于触发器支持脚本，因此要完全支持触发器功能的话需要引入<code>js执行器</code></p> <p><strong>务必设置运行资源限制，防止用户上传恶意脚本搞崩服务器。</strong></p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token comment">&lt;!-- https://mvnrepository.com/artifact/org.openjdk.nashorn/nashorn-core --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.openjdk.nashorn<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>nashorn-core<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>15.3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h4 id="条件分支"><a href="#条件分支" class="header-anchor">#</a> 条件分支</h4> <p>条件节点对应 <code>exclusive gateway</code> ，这与普通节点有所不同</p> <p><img src="https://pic.rmb.bdstatic.com/bjh/fec7f2894a598c5b50f930b3f64ac93c.png" alt="image-20220720145227591"></p> <p>如上图所示，实际上外部还有一个看不到的节点对象，将这几个子分支条件<code>包裹起来</code>，这个红色部分才是条件节点，也就是排他网关，绿色条件块应当解析为<strong>带条件的</strong><code>sequenceFlow</code>连接线，该节点内设置的条件应该作为<code>sequenceFlow</code>的条件</p> <h4 id="并行分支"><a href="#并行分支" class="header-anchor">#</a> 并行分支</h4> <p>并行分支对应<code>parallelGateway</code> ，与条件分支一样，外部也有一个对象包裹内部的并行分支，外部这个对象应该解析为<code>并行网关</code>，但是它的分支节点首部应当看做普通顺序流，由于并行网关成对存在，因此需要注意创建合流的分支，将每个子分支末端连接到合流点</p> <img src="https://pic.rmb.bdstatic.com/bjh/4ea8259c04daa76b91f8b9863d46a66e.png" alt="image-20220720150019350" style="zoom:50%;"></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/dev/process.html" class="prev">
        流程设计
      </a></span> <!----></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.5597d7ea.js" defer></script><script src="/assets/js/2.55e01133.js" defer></script><script src="/assets/js/14.a398dcf5.js" defer></script>
  </body>
</html>
